export const schema = {
    type: "page",
    title: "订单列表",
    body: {
        type: "crud",
        api: "get:/api/order",
        columnsTogglable: false,
        panelClassName: "no-border no-shadow bg-white",
        toolbarInline: true,
        showHeader: true,
        bulkActions: [
            {
                label: "通过",
                type: "button",
                level: "success",
                actionType: "ajax",
                api: "put:/api/order/pass/${ids}"
            },

            {
                label: "拒绝",
                type: "button",
                level: "danger",
                actionType: "dialog",
                dialog: {
                    title: "批量不通过",
                    body: {
                        type: "form",
                        api: "put:/api/order/refuse/${ids}",
                        controls: [
                            {
                                type: "text",
                                label: "驳回理由",
                                name: "reason"
                            }
                        ]
                    }
                }
            },
        ],
        filter: {
            title: "",
            submitText: "",
            panelClassName: 'm-b-none bg-gd no-border',
            bodyClassName: 'wrapper-sm',
            controls: [
                {
                    type: "button-group",
                    btnActiveClassName: "btn-info active",
                    value: "",
                    submitOnChange: true,
                    name: "status",
                    options: [
                        {
                            label: "全部",
                            value: ""
                        },
                        {
                            label: "待审核",
                            value: "2"
                        },
                        {
                            label: "已通过",
                            value: "0"
                        },
                        {
                            label: "拒绝",
                            value: "1"
                        }
                    ]
                },
                {
                    type: "text",
                    name: "keyword",
                    placeholder: "姓名／电话／商品名称／发布团队",
                    style: {minWidth: 260},
                    addOn: {
                        type: "submit",
                        label: "搜索",
                        primary: true
                    }
                },

                {
                    type: "button",
                    label: "导出",
                    level: "info",
                    actionType: "url",
                    url: "/api/order?asExcel=1&keyword=${keyword}"
                }
            ]
        },
        columns: [
            {
                name: "id",
                label: "订单ID"
            },
            {
                name: "goods_info.type",
                label: "商品类型",
                type: 'map',
                map: {
                    1: '优惠券',
                    0: '实物类'
                }

            },
            {
                name: "goods_info.g_name",
                label: "商品名称",
                type: "tpl",
                tpl: "<a data-link='/score/goods/view/${goods_info.id}'>${goods_info.g_name}</a>"
            },
            {
                name: "org_id",
                label: "所属机构",
                type: "tpl",
                tpl: `<% if (data.acl.can("org:view")) { %>
                    <a data-link='/org/view/<%= data.org_info.id %>'><%= data.org_info.name %></a>
                    <% } else { %>
                        <span><%= data.org_info.name %></span>
                        <% } %>`
            },
            {
                name: "team_info.name",
                label: "发布团队"
            },
            {
                name: "goods_info.price",
                label: "商品价格"
            },
            {
                name: "goods_info.points",
                label: "消耗积分"
            },
            {
                name: "user_info.username",
                label: "兑换人"
            },
            {
                name: "success_orders",
                label: "联系电话"
            },
            // {
            //     name: "",
            //     label: "收货地址"
            // },
            // {
            //     name: "",
            //     label: "领取方式"
            // },

            {
                name: "status",
                width: 80,
                label: "审核状态",
                type: "map",
                map: {
                    "1": '<span class="label label-default">拒绝</span>',
                    "2": '<span class="label label-default">待审核</span>',
                    "0": '<span class="label label-success">通过</span>'
                }
            },
            {
                name: "state",
                width: 80,
                label: "兑换状态",
                type: "map",
                map: {
                    "1": '<span class="label label-default">已领取</span>',
                    "0": '<span class="label label-success">未领取</span>'
                }
            },
            {
                label: "订单时间",
                name: "created_at",
                type: 'tpl',
                tpl: "${created_at|date:LL:YYYY-MM-DD HH:mm:ss}"
            },

            {
                label: "操作",
                type: "operation",
                width: 180,
                buttons: [

                    {
                        type: "button",
                        size: "xs",
                        label: "设为领取",
                        level: "success",
                        confirmText: "确定设为领取？设置后将不可改变",
                        actionType: "ajax",
                        api: "put:/api/order/$id",
                        visibleOn: "data.state == 0"
                    },
                ]
            }
        ]
    }
};
